﻿using Microsoft.Xna.Framework;

namespace block_explorer
{
    class EntityCamera : OrientableCamera
    {
        protected BaseEntity mEntity;
        protected Vector3 mOffset;

        public BaseEntity Entity { get { return mEntity; } set { mEntity = value; } }
        public Vector3 Offset { get { return mOffset; } set { mOffset = value; } }

        public EntityCamera(Vector3 offset, int viewWidth, int viewHeight, float fov, float near, float far)
            : base(viewWidth, viewHeight, fov, near, far)
        {
            mEntity = null;
            mOffset = offset;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (mEntity != null)
            {
                Position = mEntity.Position + mOffset;
                Orientation = mEntity.Orientation;
            }
            else
            {
                Position = Vector3.Zero;
                Orientation = Quaternion.Identity;
            }
        }
    }
}
